<?php

class Application_Model_DbTable_Supply extends Zend_Db_Table_Abstract {
    protected $_name = 'Supply';
    
    public function getAllSupply($supplyTypeId){
       $result = array();
       if(empty($supplyTypeId)){
       $sql = "select s.ID, s.Ref,s.Photo,s.Name,s.Supplier,t.Name as Category ,s.Price,s.Exception from Supply s left join SupplyType t on s.SuppylyTypeId = t.ID ";
       $result = $this->getAdapter()->fetchAssoc($sql); 
       }else{
       $sql = "select s.ID, s.Ref,s.Photo,s.Name,s.Supplier,t.Name as Category ,s.Price,s.Exception from Supply s left join SupplyType t on s.SuppylyTypeId = t.ID where s.SuppylyTypeId = ".intval($supplyTypeId);
       $result = $this->getAdapter()->fetchAssoc($sql);    
       }
       
       return $result;
    }
    
    public function getSupply($sid){        
        $result = $this->find($sid);
        return $result;
    }
   
}
